package com.leno.mmall.controller.backend;

import com.leno.mmall.common.Const;
import com.leno.mmall.common.ResponseCode;
import com.leno.mmall.common.ServerResponse;
import com.leno.mmall.pojo.User;
import com.leno.mmall.service.ICategoryService;
import com.leno.mmall.service.IOrderService;
import com.leno.mmall.service.IProductService;
import com.leno.mmall.service.IUserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/manage/statistic/")
public class StatisticManafeController {
    @Resource
    public IUserService iUserService;
    @Resource
    public IProductService iProductService;
    @Resource
    public IOrderService iOrderService;

//####1.统计用户、商品、订单数量  未完成
//@RequestMapping("base_count.do")
//public ServerResponse baseCount(HttpSession session) {
//    User user = (User) session.getAttribute(Const.CURRENT_Admin);
//    if (user == null) {
//        return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), "请用管理员登录");
//    }
//    if (iUserService.checkAdminRole(user).isSuccess()) {
//        int userCount=iUserService.userCount();
//        int productCount=iProductService.productCount();
//        int orderCount=iOrderService.orderCount();
//        Map map=new HashMap();
//        map.put("userCount",userCount);
//        map.put("productCount",productCount);
//        map.put("orderCount",orderCount);
//        return ServerResponse.createBySuccess(map);
//    } else {
//        return ServerResponse.createByErrorMessage("无权限操作");
//    }
//}
}
